<?
require_once("../config/dbconn.php");require_once("../config/usercls.php");require_once("../config/pagecls.php");

if($action=='del'){
	$sql="select * from {$db_prefix}msgs where id='$id' and username='".$_SESSION['sys_username']."'";
	$rs=$db->get_one($sql);
	$db->delete("{$db_prefix}msgs","id='{$rs['id']}'");
	echo "<script>location.href='msg_lst.php?pageno={$pageno}';</script>";exit();
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
		
}
td{
font-size:12px;
}
-->
</style>

<link href="images/skin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17" height="29" valign="top" ></td>
    <td width="100%" height="29" valign="top" ><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31" border="1"><div class="titlebt">&nbsp;&nbsp;留言列表</div></td>
      </tr>
    </table></td>
    <td width="16" valign="top" ></td>
  </tr>
  <tr>
    <td height="71" valign="middle" >&nbsp;</td>
    <td valign="top"><table width="100%" height="138" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="13" valign="top">&nbsp;</td>
      </tr>
      <tr>
        <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="nowtable">
                <tr>
                  <td class="left_bt2">&nbsp;</td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td height="30"><table width="100%" height="60" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td width="14%" height="30" align="center" bgcolor="#f2f2f2" >留言给管理员</td>
                  <td width="53%" align="center" bgcolor="#f2f2f2" >标题</td>
                  <td width="14%" align="center" bgcolor="#f2f2f2" >留言时间</td>
                  <td width="9%" align="center" bgcolor="#f2f2f2" >回复状态</td>
                  <td width="10%" align="center" bgcolor="#f2f2f2" >操作</td>
                  </tr>
				  <?
  $query='';
  if ($act=='query'){
	
  }
  
  $sql="select count(id) as c  from {$db_prefix}msgs where username='".$_SESSION['sys_username']."'";
  if ($query!='') $sql.=$query;
  $rs=$db->get_one($sql);
  $page=new pagecls(20,intval($rs['c']));
  $sql="select * from {$db_prefix}msgs where username='".$_SESSION['sys_username']."'";
  if ($query!='') $sql.=$query;
  $sql.=" order by id desc limit {$page->pastnum},{$page->pagesize}";
  $result=$db->query($sql);
  while($rs=$db->fetch_array($result)){
  ?>
                <tr>
                  <td height="30" align="center">
                    <?
					$sqlgly="select * from {$db_prefix}admin888 where id='{$rs['glyid']}'";
					$rsgly=$db->get_one($sqlgly);
					echo $rsgly['nickname'];
					?>                 </td>
                  <td align="center" ><a href="msg_view.php?id=<?=$rs['id']?>">
                    <?=$rs['title']?>
                  </a></td>
                  <td align="center" ><?=date("Y-m-d H:i:s",$rs['addtime'])?></td>
                  <td align="center"  style="color:#FF0000"><?
				  if ($rs['replytime']>0) echo date('Y-m-d H:i:s',$rs['replytime'])."已回复";else echo "未回复";
				  ?></td>
                  <td align="center"  style="color:#FF0000"><a href="?action=del&id=<?=$rs['id']?>&pageno=<?=$page->pageno?>" onClick="return confirm('确定删除吗?')">删除</a></td>
                  </tr>
				   <?
  }
  $db->free_result($result);
  ?>
              </table></td>
            </tr>
            
            <tr>
              <td height="30">&nbsp;</td>
            </tr>
            <tr>
              <td height="30" align="right">每页<?=$page->pagesize?>条 第<?=$page->pageno?>/<?=$page->pagenum?>页共<?=$page->recnum?>条 <a href='?<?=$page->url?>1'><img src="image1/first.gif" border="0"></a>   <a href='?<?=$page->url.($page->pageno-1)?>'><img src="image1/back.gif" border="0"></a>  <a href='?<?=$page->url.($page->pageno+1)?>'><img src="image1/next.gif" border="0"></a>   <a href='?<?=$page->url.$page->pagenum?>'><img src="image1/last.gif" border="0"></a></td>
              </tr>
            <tr>
              <td height="30">&nbsp;</td>
            </tr>
          </table></td>
      </tr>
    </table></td>
    <td >&nbsp;</td>
  </tr>
  <tr>
    <td valign="middle" ></td>
      <td height="17" valign="top" ></td>
    <td></td>
  </tr>
</table>

</body>
</html>
